package cn.initcap.concurrency.concurrency.concurrent;

import cn.initcap.concurrency.annoations.ThreadSafe;
import cn.initcap.concurrency.concurrency.ThreadPoolCreatHelper;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;
import lombok.extern.slf4j.Slf4j;

/**
 * @author initcap
 * @date Created in 2018/6/16 PM3:38.
 */
@Slf4j
@ThreadSafe
public class ConcurrentSkipListMapExample {

    /**
     * 总请求数
     */
    private static final int CLIENT_TOTAL = 5000;

    /**
     * 同时并发执行的线程数
     */
    private static final int THREAD_TOTAL = 200;

    private static Map<Integer, Integer> map = new ConcurrentSkipListMap<>();

    public static void update(int i) {
        map.put(i, i);
    }

    public static void main(String[] args) throws Exception {
        ThreadPoolCreatHelper.threadFinalCountParam(CLIENT_TOTAL, THREAD_TOTAL,
                ConcurrentSkipListMapExample.class, "update",
                "ConcurrentSkipListMapExample");
        log.info("size:{}", map.size());
    }

}
